package com.cd.hospital.www.web;

import java.util.List;
import java.util.Map;

import com.cd.hospital.common.utils.PageUtils;
import com.cd.hospital.common.utils.Query;
import com.cd.hospital.common.utils.R;
import com.cd.hospital.modules.entity.AdvertisementEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.cd.hospital.modules.entity.DepartmentTagsEntity;
import com.cd.hospital.modules.service.DepartmentTagsService;




/**
 * 科室标签
 * 
 * @author weirdor
 * @email 179946422@qq.com
 * @date 2017-10-12 16:32:38
 */
@RestController
@RequestMapping("/modules/departmenttags")
public class DepartmentTagsController {
	@Autowired
	private DepartmentTagsService departmentTagsService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("modules:departmenttags:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<DepartmentTagsEntity> departmentTagsList = departmentTagsService.queryList(query);
		int total = departmentTagsService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(departmentTagsList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}

	/**
	 * 列表
	 */
	@RequestMapping("/lists")
	@RequiresPermissions("modules:departmenttags:list")
	public R lists(@RequestParam Map<String, Object> params){
		List<DepartmentTagsEntity> advertisementList = departmentTagsService.queryAllAt();
		return R.ok().put("departmentTags", advertisementList);
	}
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("modules:departmenttags:info")
	public R info(@PathVariable("id") Integer id){
		DepartmentTagsEntity departmentTags = departmentTagsService.queryObject(id);
		
		return R.ok().put("departmentTags", departmentTags);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("modules:departmenttags:save")
	public R save(@RequestBody DepartmentTagsEntity departmentTags){
		departmentTagsService.save(departmentTags);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("modules:departmenttags:update")
	public R update(@RequestBody DepartmentTagsEntity departmentTags){
		departmentTagsService.update(departmentTags);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("modules:departmenttags:delete")
	public R delete(@RequestBody Integer[] ids){
		departmentTagsService.deleteBatch(ids);
		
		return R.ok();
	}
	
}
